package com.ruoyi.reportInfo.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.reportInfo.domain.vo.IndustrialParkVo;
import com.ruoyi.reportInfo.domain.bo.IndustrialParkBo;
import com.ruoyi.reportInfo.service.IIndustrialParkService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 园区信息
 *
 * @author yangzhen
 * @date 2025-11-24
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/reportInfo/park")
@Tag(name = "园区信息", description = "园区信息相关接口")
public class IndustrialParkController extends BaseController {

    private final IIndustrialParkService iIndustrialParkService;

    /**
     * 查询园区信息列表
     */
    @SaCheckPermission("reportInfo:park:list")
    @GetMapping("/list")
    @Operation(summary = "查询园区信息列表", description = "用于查询园区信息列表")
    public TableDataInfo<IndustrialParkVo> list(IndustrialParkBo bo, PageQuery pageQuery) {
        return iIndustrialParkService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出园区信息列表
     */
    @SaCheckPermission("reportInfo:park:export")
    @Log(title = "园区信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出园区信息列表", description = "用于导出园区信息列表")
    public void export(IndustrialParkBo bo, HttpServletResponse response) {
        List<IndustrialParkVo> list = iIndustrialParkService.queryList(bo);
        ExcelUtil.exportExcel(list, "园区信息", IndustrialParkVo.class, response);
    }

    /**
     * 获取园区信息详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("reportInfo:park:query")
    @GetMapping("/{id}")
    @Operation(summary = "获取园区信息详细信息", description = "用于获取园区信息详细信息")
    public R<IndustrialParkVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable String id) {
        return R.ok(iIndustrialParkService.queryById(id));
    }

    /**
     * 新增园区信息
     */
    @SaCheckPermission("reportInfo:park:add")
    @Log(title = "园区信息", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增园区信息", description = "用于新增园区信息")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody IndustrialParkBo bo) {
        return toAjax(iIndustrialParkService.insertByBo(bo));
    }

    /**
     * 修改园区信息
     */
    @SaCheckPermission("reportInfo:park:edit")
    @Log(title = "园区信息", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改园区信息", description = "用于修改园区信息")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody IndustrialParkBo bo) {
        return toAjax(iIndustrialParkService.updateByBo(bo));
    }

    /**
     * 删除园区信息
     *
     * @param ids 主键串
     */
    @SaCheckPermission("reportInfo:park:remove")
    @Log(title = "园区信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除园区信息", description = "用于删除园区信息")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable String[] ids) {
        return toAjax(iIndustrialParkService.deleteWithValidByIds(Arrays.asList(ids), true));
    }
}
